<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePermissionAndRoles extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //角色表
        Schema::create('admin_roles', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->default('')->comment('角色');
            $table->string('desc')->default('')->comment('角色描述');
            $table->timestamps();
        });
        //权限表
        Schema::create('admin_permissions', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->default('')->comment('权限');
            $table->string('desc')->default('')->comment('权限描述');
            $table->timestamps();
        });
        //用户角色表
        Schema::create('admin_role_user', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('role_id')->default(0)->comment('角色id');
            $table->integer('user_id')->default(0)->comment('管理员id');
            $table->timestamps();
        });

        //权限角色表
        Schema::create('admin_permission_role', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('role_id')->default(0)->comment('角色id');
            $table->integer('permission_id')->default(0)->comment('权限id');
            $table->timestamps();
        });

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
        Schema::drop("admin_roles");
        Schema::drop("admin_permissions");
        Schema::drop("admin_permission_role");
        Schema::drop("admin_role_user");
    }
}
